using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Globalization;

/* =====================================================================

  File:      ProductDetails.aspx.cs for Adventure Works Cycles Storefront Sample
  Summary:   Displays information about a particular product, including upsell information via 
			 the _AlsoBought.ascx user control
  Date:	     June 16, 2003

---------------------------------------------------------------------

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= */

namespace Microsoft.Samples.SqlServer 
{

    public partial class ProductDetailsPage : System.Web.UI.Page
    {

    
//         public ProductDetailsPage() {
//             Page.Init += new System.EventHandler(Page_Init);
//         }

        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // product information from a database and then update
        // UI elements with them.
        //
        // Note that this page is output cached at 1 minute
        // intervals.  This eliminates the need to hit the database
        // on each request to the page.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e) {

            // Obtain ProductID from QueryString
            int ProductID = Int32.Parse(Request.Params["ProductID"], CultureInfo.InvariantCulture);

            // Obtain Product Details
            ProductsDB products = new ProductsDB();
            ProductDetails myProductDetails = products.GetProductDetails(ProductID, WorldReady.CurrentLanguage());

            // Update Controls with Product Details
            description.Text = myProductDetails.Description;
            UnitCost.Text = myProductDetails.UnitCost;
            ModelName.Text = myProductDetails.ModelName;
            ModelNumber.Text = myProductDetails.ModelNumber.ToString(CultureInfo.InvariantCulture);
			ProductNumber.Text = ProductID.ToString(CultureInfo.InvariantCulture);
            ProductImage.ImageUrl = "ProductImages/" + myProductDetails.ProductImage;
            addToCart.NavigateUrl = "AddToCart.aspx?ProductID=" + ProductID;
            ReviewList.ProductID = ProductID;
        }

        private void Page_Init(object sender, EventArgs e) {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
        }

		#region Web Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent() {
        }
		#endregion

    }
}
